/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package MapPack;

/**
 *
 * @author Aaron
 */

import MapPack.Map;
import UtilityPack.PerlinGen;

import java.util.Random;

public class MapGenerator {
    private long mapSeed;
    private Map map;

    // Lower numbers give a higher chance.
    private int grassChance = 25;

    public MapGenerator() {
        this.mapSeed = System.currentTimeMillis();
    }
    
    public void generateMap() {
        this.map = new Map(5, 3, 4, 4);

        Random random = new Random(0);
        //Random random = new Random(mapSeed);

        PerlinGen perlinGen = new PerlinGen(1.2, .3, .3, 4, random.nextInt());

        for (Chunk chunk : map.getChunks().values()) {
            for (int i = 0; i < map.getChunkSize(); i++) {
                for (int j = 0; j < map.getChunkSize(); j++) {
                    double height = perlinGen.getHeight(chunk.getPosition().x * map.getChunkSize() + i,
                            chunk.getPosition().y * map.getChunkSize() + j);
                    if (height > .8) {
                        chunk.getCell(i, j).setCellType(Map.CellEnum.EMPTY);
                    } else if (height > .6) {
                        chunk.getCell(i, j).setCellType(Map.CellEnum.ICE);
                    } else if (height > .4) {
                        chunk.getCell(i, j).setCellType(Map.CellEnum.GRASS);
                    }
                }
            }
        }

    }

    public Map getMap ( ) {
        return this.map;
    }


    
}
